package algorithm;

public class leetcode_0096 {
    public int numTrees(int n) {
        if(n==1) return 1;
        if(n==2) return 2;
        int[] dp=new int[n+1];
        dp[0]=1;
        dp[1]=1;
        dp[2]=2;
        for(int i=3;i<=n;++i){
            for(int k=0;k<i;++k){
                dp[i]+=dp[k]*dp[i-1-k];
            }
        }
        return dp[n];
    }
}
